package com.zmzncs.shop.module.park.service.impl;

import org.springframework.beans.BeanUtils;
import com.zmzncs.shop.module.park.pojo.parkinfo.*;
import com.zmzncs.shop.module.park.mapper.ParkInfoMapper;
import com.zmzncs.shop.module.park.service.ParkInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author rr
 * @since 2020-12-31
 */
@Service
public class ParkInfoServiceImpl extends ServiceImpl<ParkInfoMapper, ParkInfo> implements ParkInfoService {

    @Autowired
    private ParkInfoMapper parkInfoMapper;

    @Override
    public IPage<ParkInfoDTO> page(ParkInfoSearchForm form){
        IPage<ParkInfoDTO> iPage = parkInfoMapper.list(form.getPage());

        return iPage;
    }

    @Override
    public void add(ParkInfoAddForm form){
        ParkInfo parkInfo = new ParkInfo();
        BeanUtils.copyProperties(form, parkInfo);

        parkInfoMapper.insert(parkInfo);
    }

    @Override
    public void delete(Long id){
        ParkInfo parkInfo = new ParkInfo();
        parkInfo.setId(id);
//        parkInfo.isDeleted(1);

        parkInfoMapper.updateById(parkInfo);
    }

    @Override
    public void update(ParkInfoUpdateForm form){
        ParkInfo parkInfo = new ParkInfo();
        BeanUtils.copyProperties(form, parkInfo);

        parkInfoMapper.updateById(parkInfo);
    }

    @Override
    public ParkInfoDTO getById(Long id){
        ParkInfoDTO parkInfoDTO = parkInfoMapper.getById(id);

        return parkInfoDTO;
    }

}
